(defun sum-digit-pow ( n pow )
  (loop for i from 1 to 10
       for j = n then (floor (/ j 10))
       while (> j 0)
       sum (expt (mod j 10) pow)))

(defun fift-pow (n)
  (= n (sum-pows n 5)))

(defun probl30 ()
 (loop for i from 2 to (* 7 (expt 9 5)) when (fift-pow i) sum i))

(defun digits(n)
  (nreverse (loop for i = n then (floor (/ i 10))
       while (> i 0)
       collect (mod i 10))))

(defun sum-pows ( n pow)
  (reduce #'+ 
	  (mapcar #'(lambda (x) (expt x pow)) (digits n))))
	  
(defun digitpows (n pow)
  (loop for i = n then (floor (/ i 10))
       for k from 1 to 10
       while (> i 0)
       sum (expt  (mod i 10) pow)))
  
(print
 (loop for i from 2 to 10000 when (= i (digitpows i 4)) collect i))